﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using System.Data;
using System.Windows.Forms;
namespace DnDDB
{
    public class Feat
    {
        string name;
        bool stackable;
        /// <summary>
        /// Creates a new feat and assumes you can stack it.
        /// </summary>
        /// <param name="name"></param>
        public Feat(string name)
        {
            this.name = name;
            this.stackable = true;
        }

        /// <summary>
        /// Creates a new feat, but you specify whether or not you can stack it.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="stackable"></param>
        public Feat(string name, bool stackable)
        {
            this.name = name;
            this.stackable = stackable;
        }



        /// <summary>
        /// Change whether or not the feat can be selected multiple times.
        /// </summary>
        /// <param name="stackable"></param>
        public void setStackable(bool stackable)
        {
            this.stackable = stackable;
        }

        /// <summary>
        /// Returns a bool that indicates whether or not the feat can be selected multiple times.
        /// </summary>
        /// <returns></returns>
        public bool getStackable()
        {
            return this.stackable;
        }

        /// <summary>
        /// Returns the name of the feat.
        /// </summary>
        /// <returns></returns>
        public string getName()
        {
            return this.name;
        }

        /// <summary>
        /// Figures out whether or not the feat can be selected multiple times by querying the database.
        /// </summary>
        public bool findStackable()
        {
            getMySQL get = new getMySQL();
            string db_command = "SELECT stackable_with_self FROM feat where name='" + this.name + "';";
            DataRow dr = get.GetMySQLFilledRow(db_command);
            if (dr["stackable_with_self"] == null || dr["stackable_with_self"].ToString() == "")
            {
                MessageBox.Show("Feat " + this.name + " does not exist!");
                return false;
            }
            this.stackable = Convert.ToBoolean(dr["stackable_with_self"]);
            return this.stackable;
        }

    }
}
